package com.carl.main;

import org.jsoup.Jsoup;

import java.io.IOException;

public class Day07_MoocCrawler {

    // 慕课网 :    http://www.imooc.com/article
    // 多线程 -- 模拟刷单请求 -- 503 -- HTTP error fetching URL
    public static void main(String[] args)throws Exception{

        for (int i = 0; i < 200; i++) {
            new Thread(new ReadThread()).start();
            Thread.sleep(50);
        }
    }

    static class ReadThread extends Thread {

        @Override
        public void run() {
            String readUrl = "http://www.imooc.com/article/284943" ;
            try {
                Jsoup.connect(readUrl).get();
                System.out.println(" \t name : " +Thread.currentThread().getName()+" == 执行完成");
            } catch (IOException e) {
                e.printStackTrace();
                System.out.println(" \t thread : " +Thread.currentThread().getName()+" -- 异常执行");
            }


        }
    }

}
